package com.wt.hrentSystem.common.util;


import com.wt.hrentSystem.common.entity.User;
import com.wt.hrentSystem.common.service.UserService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class UserUtils{
    @Autowired
    private UserService userService;
    @Autowired
    private UserUtils userUtils;

    public User getUser(HttpServletRequest request){
        String token = request.getHeader("token");
        String userId = TokenUtils.getUserId(token);
        User loginUser = new User();
        if(StringUtils.isNotBlank(userId)){
            loginUser = userService.get(userId);
        }
        return loginUser;
    }

//    @PostConstruct
//    public void init(){
//        userUtils = userUtils1;
//    }
}
